package com.zy.dp.iterator.example5;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

@SuppressWarnings("rawtypes")
public class ArrayIteratorImpl implements Iterator
{

	private PayModel[] pms = null;
	private int index = 0;

	public ArrayIteratorImpl(SalaryManager aggregate)
	{

		Collection<PayModel> tempCol = new ArrayList<PayModel>();
		for (PayModel payModel : tempCol)
		{
			if (payModel.getPay() < 3000)
			{
				tempCol.add(payModel);
			}
		}
		this.pms = new PayModel[tempCol.size()];

		int i = 0;
		for (PayModel pm : tempCol)
		{
			this.pms[i] = pm;
			i++;
		}

	}

	@Override
	public boolean hasNext()
	{
		if (pms != null && index <= (pms.length - 1))
		{
			return true;
		}
		return false;
	}

	@Override
	public Object next()
	{

		Object recObj = null;

		if (hasNext())
		{
			recObj = pms[index];
			index++;
		}

		return recObj;

	}

	@Override
	public void remove()
	{
		// TODO Auto-generated method stub

	}

}
